Passed
Pull Request — master (#17)
by
unknown
01:26
created

content.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
/* eslint-env browser, jquery, webextensions */
2
3
const $sendButton = $('<a id="send-to-omnifocus">Send to OmniFocus &raquo;</a>');
4
5
$(() => {
6
  // creates an OF task using the supplied ticket info
7
  function createTaskForTicket(ticket) {
0 ignored issues
show
Bug introduced by
The function createTaskForTicket is declared conditionally. This is not supported by all runtimes. Consider moving it to root scope or using var createTaskForTicket ...nction() { /* ... */ }; instead.
Loading history...
8
    const message = {
9
      method: 'createTask',
10
      params: {
11
        name: `[${ticket.key}] ${ticket.summary}`,
12
        note: `${window.location.href}\n\n${ticket.description}`,
13
      },
14
    };
15
16
    chrome.runtime.sendMessage(message, (data) => {
0 ignored issues
show
Bug introduced by
The variable chrome seems to be never declared. If this is a global, consider adding a /** global: chrome */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
17
      $('<iframe style="display:none">')
18
        .attr('src', data.url)
19
        .appendTo('body');
20
    });
21
  }
22
23
  $sendButton.prependTo('#viewissuesidebar');
24
25
  $sendButton.on('click', (evt) => {
26
    evt.preventDefault();
27
28
    createTaskForTicket({
29
      key: $('#key-val').text(),
30
      summary: $('#summary-val').text().replace(/\s+/, ' ').replace(/^\s*(\S.+\S)\s*$/, '$1'),
31
      description: $('#description-val').html(),
32
    });
33
  });
34
});
35